package md.mru.backend.core.domains.administration;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

/**
 * @author sergiu.marin
 * @since 23.04.2014.
 */
@Embeddable
public class TreeFolderId implements Serializable {

    private static final long serialVersionUID = 7878173710896679877L;

    @Column(name = "tree_id", unique = true, nullable = false, precision = 10, scale = 0)
    private long treeNodeModelId;

    @Column(name = "folder_id", unique = true, nullable = false, precision = 10, scale = 0)
    private long folderId;

    public TreeFolderId() {}

    public TreeFolderId(long treeNodeModelId, long folderId) {
        this.treeNodeModelId = treeNodeModelId;
        this.folderId = folderId;
    }

    public long getTreeNodeModelId() {
        return treeNodeModelId;
    }

    public void setTreeNodeModelId(long treeNodeModelId) {
        this.treeNodeModelId = treeNodeModelId;
    }

    public long getFolderId() {
        return folderId;
    }

    public void setFolderId(long folderId) {
        this.folderId = folderId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TreeFolderId that = (TreeFolderId) o;

        return folderId == that.folderId && treeNodeModelId == that.treeNodeModelId;

    }

    @Override
    public int hashCode() {
        int result = (int) (treeNodeModelId ^ (treeNodeModelId >>> 32));
        result = 31 * result + (int) (folderId ^ (folderId >>> 32));
        return result;
    }
}
